package com.dameng.system.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dameng.system.entity.SystemRole;
import org.apache.ibatis.annotations.*;

@Mapper
public interface SystemRoleMapper extends BaseMapper<SystemRole> {

    @Select("select r.*," +
            "case (select count(1) from system_user_role s where s.user_id = ur.user_id) when 0 then false " +
            "else true end checked " +
            "from system_role r left join system_user_role ur on r.role_id = ur.role_id and ur.user_id=#{userId}")
    Page<SystemRole> getRolesByUserId(Page<SystemRole> page, @Param("userId") String userId);

}
